<template>
	<view class="orders page bgff c00">

		<scroll-view scroll-y class="list boxS bgf5" @scrolltolower="nextPage">
			<block v-for="(item,index) in list" :key="index">
				<store-item :item="item" @location="location" @call="call" @detail="detail"></store-item>
			</block>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

				currentTab: 0,
				list: [],
				isnodata: false,
				isLastPage: false,
				page: 1,
				type: '',
				id:''
			};
		},
		onLoad(option) {
			this.id = option.id;
			this.getList();
		},
		methods: {

	location(item) {
				uni.openLocation({
						name: item.name,
						latitude: parseFloat(item.lat),
						longitude: parseFloat(item.lng),
						address: item.address,
						fail: function(res) {
							console.info(JSON.stringify(res))
						}
					},
					
				)
				console.log("location" + JSON.stringify(item))
			},
			call(item) {

				uni.makePhoneCall({
					phoneNumber: item.tel
				})
				console.log("call" + JSON.stringify(item))

			},
			detail(item) {
				console.log("detail" + JSON.stringify(item))
				uni.navigateTo({
					url:'../shop/detail?id='+item.id+"&distance="+item.distance
				})
			},

			nextPage() {
				if (this.isLastPage) return;
				this.page += 1;
				this.getList();
			},

			getList() {
				let param = {
					id: this.id,
				};
				let that = this;
				this.$api.balanceShopList(param).then(res => {
					console.info(JSON.stringify(res));
					if (res.code == 1) {
						let length = res.data.length;
						for (let i = 0; i < length; i++) {
							that.list.push(res.data[i]);
						}
						
					} else {

					}
				})
			}

		}
	}
</script>

<style lang="scss" scoped>
	.orders {
		.active {
			border-bottom: 4rpx solid #576DAB;
		}

		.list {
			height: calc(100vh - 92rpx);
		}
	}
</style>
